﻿Public Class login1
    Inherits System.Web.UI.Page
    Dim con As SqlServerCe.SqlCeConnection = New SqlServerCe.SqlCeConnection("Data Source='c:\users\mauhib\documents\visual studio 2010\Projects\WebApplication5\WebApplication5\App_Data\MyData.sdf'")
    Dim sda As SqlServerCe.SqlCeDataAdapter
    Dim dt As New DataTable

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        sda = New SqlServerCe.SqlCeDataAdapter("SELECT * from Users", con)
        sda.Fill(dt)
        Label1.Text = dt.Rows.Count
    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        For Each dr As DataRow In dt.Rows
            If dr("User_Nick") = Nick.Text Then
                If dr("User_pass") = Pass.Text Then
                    Session.Add("User_Nick", dr("User_Nick"))
                    Response.Redirect("Default.aspx")
                Else
                    Label1.Visible = True
                    Label1.Text = "Incorrect Password"
                End If
            Else
                Label1.Visible = True
                Label1.Text = "Nickname not found"
            End If
        Next
    End Sub

    Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Response.Redirect("WebForm1.aspx")
    End Sub
End Class